using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Iacym.Entities;

namespace Iacym.Repository.Mapping
{
    public class DETALLE_CARGOMap : EntityTypeConfiguration<DETALLE_CARGO>
    {
        public DETALLE_CARGOMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Ministerio)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("DETALLE_CARGO");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.PersonaId).HasColumnName("PersonaId");
            this.Property(t => t.CargoId).HasColumnName("CargoId");
            this.Property(t => t.Ministerio).HasColumnName("Ministerio");

            // Relationships
            this.HasRequired(t => t.CARGO)
                .WithMany(t => t.DETALLE_CARGO)
                .HasForeignKey(d => d.CargoId);
            this.HasRequired(t => t.PERSONA)
                .WithMany(t => t.DETALLE_CARGO)
                .HasForeignKey(d => d.PersonaId);

        }
    }
}
